﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using Passwords.Models;

namespace Passwords.Utils
{
    /// <summary>
    /// Converts AppDisplayMode into bool and vice versa, using parameter as reference AppDisplayMode.
    /// This converter is used by RadioButtons.
    /// </summary>
    public class AppDisplayModeToBoolConverter:IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            AppDisplayMode mode = (AppDisplayMode)value;
            AppDisplayMode target = (AppDisplayMode)parameter;

            return mode == target;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            // Note that a radio button would only set the value back to true:
            AppDisplayMode target = (AppDisplayMode)parameter;
            bool v = (bool)value;
            if (v) return target; else return null;
        }
    }
}
